<template>
  <div>
    <div>接收的数据对象-----{{ data }}</div>
  </div>
</template>
<script setup lang="ts">
import useMqtt from "@/utils/mqtt/usemqtt";
//mqtt 参数配置
const options = {
  clean: true,
  clientId: "emqx_vue3_" + Math.random().toString(16).substring(2, 8),
  connectTimeout: 30 * 1000, // ms,
  host: "192.168.221.62",
  password: "admin111",
  port: 8083,
  protocol: "ws",
  reconnectPeriod: 4000, // ms
  username: "admin",
  subscription: { topic: "topic/mqttx", qos: 0 } //需要动态配置
};
// 使用hoosk函数导出的值
const { data, connection, subscription } = useMqtt(options);
console.log("connection------", connection);
console.log("subscription----------", subscription);
</script>
 
<style scoped lang="scss"></style>